clear			all
set 			more off
set 			matsize 11000
cd 				"~/Dropbox/Indonesia Migration/" // Specify your root directory here
/*******************************************************************************
				Employment
********************************************************************************/
use				"Data/Merged", clear
label 			var per_immig_cst_5Y "Population share of new migrants in year t"
label 			var per_immig_cst_5Y_lag "Population share of new migrants in year t-5"

foreach 		var in emp native_emp mig_emp_o mig_emp_n {
replace			prop_`var' = prop_`var' * 100
}

keep 			if inlist(year,1980,1990,2000,2010)
/*******************************************************************************
				Conventional shift-share instrument
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first			
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_1.xls", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_1.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_1.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_1.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
/*******************************************************************************
				Shift-share instrument with 10-year lag
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first			
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_2.xls", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_2.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_2.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_2.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
/*******************************************************************************
				Multiple lag instrument
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_3.xls", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_3.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_3.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)

ivreg2			prop_mig_emp_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_IPConly_3.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)

				
				
				
				
/*******************************************************************************
				Employment
********************************************************************************/
use				"Data/Merged", clear
label 			var per_immig_cst_5Y "Population share of new migrants in year t"
label 			var per_immig_cst_5Y_lag "Population share of new migrants in year t-5"

foreach 		var in emp native_emp mig_emp_o mig_emp_n {
replace			prop_`var' = prop_`var' * 100
}

keep 			if inlist(year,1976,1985,1995,2005)
/*******************************************************************************
				Conventional shift-share instrument
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first			
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_1.xls", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_1.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_1.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_5Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_1.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
/*******************************************************************************
				Shift-share instrument with 10-year lag
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first			
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_2.xls", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_2.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_2.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_n (per_immig_cst_5Y = pred_per_immig_cst_10Y_5Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first				
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_2.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat ", `: di %9.2f `e(widstat)'', ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
/*******************************************************************************
				Multiple lag instrument
********************************************************************************/
ivreg2			prop_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_3.xls", excel tex replace dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_native_emp (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_3.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
				
ivreg2			prop_mig_emp_o (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_3.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)

ivreg2			prop_mig_emp_n (per_immig_cst_5Y per_immig_cst_5Y_lag = ///
				pred_per_immig_cst_10Y_5Y pred_per_immig_cst_Jaeger_10Y) ///
				i.year#i.geolev1 i.geolev2 av_high_educ_ct prop_male_ct av_age_ct, ///
				cl(geolev1) first	
mat				c = e(first)
local			SWF1= c[8,1]
local			SWF2= c[8,2]
su				`e(depvar)' if e(sample) == 1, d				
local			meandv=r(mean)
outreg2			using "Tables/Employment_Supasonly_3.xls", excel tex append dec(4) ///
				keep(per_immig_cst_5Y per_immig_cst_5Y_lag) label nocons nonotes ///
				addtext("Sanderson-Windmeijer F-Stat 1", `: di %9.2f `SWF1'', ///
				"Sanderson-Windmeijer F-Stat 2", `: di %9.2f `SWF2'', ///
				"Kleibergen-Paap rk LM statistic", `: di %9.2f `e(idstat)'', ///
				"p-value", "[`: di %9.2f `e(idp)'']", ///
				"Mean of DV", `: di %9.2f `meandv'', "# of provinces", ///
				`e(N_clust)', "District FE", YES, "Province-year FE", YES)
